﻿//销售订单 确认（审核）
var columns =
            [
                 { display: 'Key', name: 'ID', type: 'text', hide: 1 },
                { display: '销售单号', name: 'ProductSellBillNo', mintWidth: 80, width: 120 }, //, type: 'int', mintWidth: 40, width: 100
                 {display: '客户端订单号', name: 'ClientOrderNo', mintWidth: 80, width: 120 },
                { display: '销售时间', name: 'SellTime', mintWidth: 100, width: 140, type: 'selfDate' },
//  { display: '订单状态', name: 'BillState', mintWidth: 60, width: 80 },
               {display: '销售金额', name: 'SellMoney', mintWidth: 80, width: 100 },
               { display: '客户名称', name: 'ClientName', mintWidth: 100, width: 140 },
               // { display: '是否结算', name: 'SettleState', mintWidth: 100, width: 140 },
                { display: '送货人', name: 'SenderName', mintWidth: 80, width: 100 },
                //{ display: '删除状态', name: 'DeleteState', mintWidth: 80, width: 140 },
                { display: '仓库名称', name: 'StorehouseName', mintWidth: 80, width: 140 },
                { display: '销售人员', name: 'SellerName', mintWidth: 80, width: 100 },
                { display: '制单人', name: 'CreateName', mintWidth: 80, width: 100 },
                 { display: '是否审核', name: 'AuditStateName', mintWidth: 100, width: 140 },
                 { display: '审核时间', name: 'AuditTime', mintWidth: 100, width: 140, type: 'selfDate' },
                  { display: '审核人员', name: 'AuditorName', mintWidth: 80, width: 100 }
             ];

var manager;
//init controls
$(document).ready(function () {
    initligerGrid();
});

function initligerGrid() {
    manager = null;
    manager = $("#ProductOutBillGrid").ligerGrid({
        columns: columns,
        title: '销售管理',
        showTitle: true,
        width: '100%',
        enabledSort: true,
        height: '99%',
        checkbox: false,
        rownumbers: true,
        toolbar: { items: [{ text: '审核', click: auditOperation, icon: 'modify'}] },
        url: "../ProductOut/GetJsonOfProductOutBills?rand=" + Math.random()
    });
}


//auditOperation
function auditOperation() {
    var row = manager.getSelectedRow();
    if (!row) { $.ligerDialog.success('请选择需要审核的行！'); return; }
    $.ligerDialog.confirm('请选择需要审核该行？', function (yes) {
        if (yes) {
            $.get("../ProductOut/Audit?billId=" + row["ID"].toString() + "&rand=" + Math.random(), {}, function (data) {
                if (data != undefined && data == "9") {
                    initligerGrid();
                }
            });
        }
    });
}

